home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-08-29 | 2.2 KB | 80 lines | [TEXT/MPS ] |
- {$S Utilities}
-
- (* ------------------------------------------------- *)
- (* UTILITIES UNIT *)
- (* ------------------------------------------------- *)
- (* Purpose: Provide 'nicety' functions for the About *)
- (* credits box of this demo program. *)
- (* ------------------------------------------------- *)
-
- UNIT Utilities;
-
- INTERFACE
-
- USES
- Memtypes, Quickdraw, OSIntf, ToolIntf, PackIntf;
-
- PROCEDURE BoldButton (DPtr : DialogPtr;
- ItemNum : integer);
-
- PROCEDURE CenterWindow(VAR theWindowPtr : DialogPtr;
- bumpUp : integer);
-
- IMPLEMENTATION
-
- PROCEDURE BoldButton;
-
- VAR
- iBox : Rect;
- iType : integer;
- iHandle : Handle;
- oldPenState : PenState;
-
- BEGIN { BoldButton }
- SystemTask;
- { New graf port is dialog box }
- SetPort(DPtr);
- GetPenState(oldPenState);
- GetDItem(DPtr, itemNum, iType, iHandle, iBox);
- InsetRect(iBox, -4, -4);
- PenSize(3, 3);
- FrameRoundRect(iBox, 16, 16);
- SetPenState(oldPenState);
- END; { BoldButton }
-
-
- PROCEDURE CenterWindow;
-
- CONST
- menuBar = 21; { The menu bar is 21 pixels high }
-
- VAR
- dialogHeight, dialogWidth: integer;
- centerTop, centerLeft: integer;
- pixels : integer;
- temp : real;
-
- BEGIN { CenterWindow }
- { Get the bounds of the dialog itself }
- dialogHeight := theWindowPtr^.portRect.bottom - theWindowPtr^.portRect.top;
- dialogWidth := theWindowPtr^.portRect.right - theWindowPtr^.portRect.left;
- { Compute centering information }
- centerTop := (screenbits.bounds.bottom + menuBar - dialogHeight) div 2;
- centerLeft := (screenbits.bounds.right - dialogWidth) div 2;
- pixels := 0;
- { Did the programmer want this window raised slightly? }
- IF (bumpUp > 0) AND (bumpUp < 80) THEN
- BEGIN
- { Use a temporary variable, because trunc() has bug on intermediate exprs }
- temp := centerTop * (bumpUp / 100.0);
- pixels := trunc(temp);
- centerTop := centerTop - pixels;
- END;
- { Make it visible & show it! }
- MoveWindow(theWindowPtr, centerLeft, centerTop, true);
- ShowWindow(theWindowPtr);
- END; { CenterWindow }
-
- END.
-
-